package com.lanou.projecta_163news.adapter.newsAdapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import com.lanou.projecta_163news.R;

import java.util.ArrayList;

/**
 * Created by dllo on 16/3/7.
 */
public class NewsAdapter extends FragmentPagerAdapter {
    private ArrayList<Fragment> NewsData;
    private String[] titles = {"", "", "", ""};
    private int[] imageView = {R.drawable.icon_yuandian, R.drawable.icon_yuandian,
            R.drawable.icon_yuandian, R.drawable.icon_yuandian};
    private Context context;

    public NewsAdapter(FragmentManager fm, ArrayList<Fragment> NewsData, Context context) {
        super(fm);
        this.NewsData = NewsData;
        this.context = context;
    }

    @Override
    public Fragment getItem(int position) {
        return NewsData.get(position);
    }

    @Override
    public int getCount() {
        return NewsData.size();
    }

    public View getTabView(int position) {
        View view = LayoutInflater.from(context).inflate(R.layout.tab_layout, null);
        ImageView iv = (ImageView) view.findViewById(R.id.yuandian);
        iv.setImageResource(imageView[position]);
        return view;
    }

}
